import './public-path.js';
/** init domain config */
import './config'

import Vue from 'vue'
import App from './App.vue'
import Storage from 'vue-ls'
import router from './router'
import store from './store/'
import { VueAxios } from "@/utils/request"
import infiniteScroll from 'vue-infinite-scroll'
import { USER_INFO } from '@/store/mutation-types'
// import ViewUI from "view-design";
// import "view-design/dist/styles/iview.css";

require('@jeecg/antd-online-mini')
require('@jeecg/antd-online-mini/dist/OnlineForm.css')
require('@/utils/wflow/customUtil')


import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import Antd, { version } from 'ant-design-vue'


import Viser from 'viser-vue'
import 'ant-design-vue/dist/antd.less';  // or 'ant-design-vue/dist/antd.less'

import '@/permission' // permission control
import '@/utils/filter' // base filter
import Print from 'vue-print-nb-jeecg'
import VueEasyPrint from 'vue-easy-print'
/*import '@babel/polyfill'*/
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
import SSO from '@/cas/sso.js'
 import "../src/assets/iconFont/iconFont.css" 
// import "../src/assets/iconFont/iconFont.js"   
// import '../src/components/iconSvg/iconFont'
// import '../src/components/iconSvg/iconFont'


import {
  ACCESS_TOKEN,
  DEFAULT_COLOR,
  DEFAULT_THEME,
  DEFAULT_LAYOUT_MODE,
  DEFAULT_COLOR_WEAK,
  SIDEBAR_TYPE,
  DEFAULT_FIXED_HEADER,
  DEFAULT_FIXED_HEADER_HIDDEN,
  DEFAULT_FIXED_SIDEMENU,
  DEFAULT_CONTENT_WIDTH_TYPE,
  DEFAULT_MULTI_PAGE
} from "@/store/mutation-types"
import config from '@/defaultSettings'

import JDictSelectTag from './components/dict/index.js'
import hasPermission from '@/utils/hasPermission'
import vueBus from '@/utils/vueBus';
import JeecgComponents from '@/components/jeecg/index'
import '@/assets/less/JAreaLinkage.less'
import VueAreaLinkage from 'vue-area-linkage'
import '@/components/jeecg/JVxeTable/install'
import '@/components/JVxeCells/install'



import vueEsign from 'vue-esign'
import "@/assets/wflow/iconfont/iconfont.css"


// import Ellipsis from '@/components/wflow/Ellipsis'
// import WDialog from '@/components/wflow/WDialog'
// import Tip from '@/components/wflow/Tip'

import wFlowComponent from './components/wflow/index.js'

// // 引入bpmn插件
// import "bpmn-js/dist/assets/diagram-js.css";
// import "bpmn-js/dist/assets/bpmn-font/css/bpmn.css";
// import "bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css";
import Viewer from 'v-viewer' // 引入js
import 'viewerjs/dist/viewer.css' // 引入css

// //引入echarts
import * as echarts from 'echarts';
import 'echarts-liquidfill'
Vue.prototype.$echarts = echarts;

// //For IM add by nbacheng 2022-08-17
// Vue.use(ElementUI);
// Vue.use(ViewUI);
// //for formdesigner  add by nbchang 2022-09-03
// Vue.use(formDesigner);
// //Vue.use(highlightPlugin);//for highlightjs add by nbchang 2022-09-20

//表单验证
import { rules } from '@/utils/rules'
import WS from '@/utils/websocket'   //引入全局websocket
Vue.prototype.rules = rules
Vue.prototype.$ws = WS
Vue.config.productionTip = false
Vue.use(Storage, config.storageOptions)
Vue.use(ElementUI);
Vue.use(Antd)
Vue.use(VueAxios, router)
Vue.use(Viser)
Vue.use(hasPermission)
Vue.use(JDictSelectTag)
Vue.use(Print)
Vue.use(VueEasyPrint)
Vue.use(preview)
Vue.use(vueBus);
Vue.use(JeecgComponents);
Vue.use(VueAreaLinkage);
Vue.use(infiniteScroll)
 // Vue.use(Ellipsis);
// Vue.use(WDialog);
// Vue.use(Tip);
Vue.use(vueEsign)
Vue.use(Viewer)
// Vue.use(WflowComponents)
Vue.use(wFlowComponent)

Vue.prototype.$isNotEmpty = function(obj){
  return (obj !== undefined && obj !== null && obj !== '' && obj !== 'null')
}
Vue.prototype.$getDefalut = function(obj, key, df){
  return (obj === undefined || key === undefined || !this.$isNotEmpty(obj[key])) ? df : obj[key];
}

Vue.prototype.$deepCopy = function (obj){return JSON.parse(JSON.stringify(obj))}

Vue.config.productionTip = false;
 
let instance = null;
 
function render(props = {}) {
  const { container } = props;
  instance = new Vue({
    router,
    store,
    mounted () {
      store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, true))
      store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, config.navTheme))
      store.commit('TOGGLE_LAYOUT_MODE', Vue.ls.get(DEFAULT_LAYOUT_MODE, config.layout))
      store.commit('TOGGLE_FIXED_HEADER', Vue.ls.get(DEFAULT_FIXED_HEADER, config.fixedHeader))
      store.commit('TOGGLE_FIXED_SIDERBAR', Vue.ls.get(DEFAULT_FIXED_SIDEMENU, config.fixSiderbar))
      store.commit('TOGGLE_CONTENT_WIDTH', Vue.ls.get(DEFAULT_CONTENT_WIDTH_TYPE, config.contentWidth))
      store.commit('TOGGLE_FIXED_HEADER_HIDDEN', Vue.ls.get(DEFAULT_FIXED_HEADER_HIDDEN, config.autoHideHeader))
      store.commit('TOGGLE_WEAK', Vue.ls.get(DEFAULT_COLOR_WEAK, config.colorWeak))
      store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, config.primaryColor))
      store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
      store.commit('SET_MULTI_PAGE',Vue.ls.get(DEFAULT_MULTI_PAGE,config.multipage))
    },
    render: h => h(App)
  }).$mount(container ? container.querySelector('#app') : '#app');
}
 
// 非qiankun环境下，也能独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}
 
/**
 * bootstrap 只会在微应用初始化的时候调用一次，下次微应用重新进入时会直接调用 mount 钩子，不会再重复触发 bootstrap。
 * 通常我们可以在这里做一些全局变量的初始化，比如不会在 unmount 阶段被销毁的应用级别的缓存等。
 */
export async function bootstrap() {}
/**
 * 应用每次进入都会调用 mount 方法，通常我们在这里触发应用的渲染方法
 */
export async function mount(props) {
  render(props);
}
/**
 * 应用每次 切出/卸载 会调用的方法，通常在这里我们会卸载微应用的应用实例
 */
export async function unmount() {
  instance.$destroy();
  instance.$el.innerHTML = '';
  instance = null;
}